package MULE.Model;

import java.awt.Color;
import java.util.ArrayList;
import java.util.EnumSet;

/**
 * An enumeration of possible player colors.
 */
public enum PlayerColor {

	RED(new Color(227, 15, 0)), ORANGE(Color.ORANGE),
	// YELLOW(Color.YELLOW),
	GREEN(new Color(0, 196, 3)), BLUE(new Color(0, 98, 255)), VIOLET(
			Color.MAGENTA);

	private Color color;

	private PlayerColor(Color color) {
		this.color = color;
	}

	public Color getColor() {
		return this.color;
	}

	/**
	 * Returns a list containing all PlayerColor names as strings.
	 * 
	 * @return String array containing player color names.
	 */
	public static String[] getColorNames() {
		// Generate array of Player.Race names.
		ArrayList<String> colorNames = new ArrayList<String>();
		for (PlayerColor color : EnumSet.allOf(PlayerColor.class)) {
			colorNames.add(color.toString());
		}
		return colorNames.toArray(new String[colorNames.size()]);
	}

	/**
	 * Returns the Player.PlayerColor type corresponding to the given string.
	 * 
	 * @param colorName
	 *            Name of race as string.
	 * @return Player.PlayerColor type that matches given string.
	 */
	public static Color getColor(String colorName) {
		// Look for color name in list.
		for (PlayerColor color : EnumSet.allOf(PlayerColor.class)) {
			if (color.toString().equals(colorName)) {
				return color.getColor();
			}
		}
		return null;
	}
}